<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class Message extends BaseValidate
{
    //验证规则
    protected $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require|array');
    }


    public function sceneSelect()
    {
        return $this->append("param", "require|array")
            ->append("param.filter", "array");
    }

    // ClearChatUnread 验证场景定义
    public function sceneClearMessageUnread()
    {
        return $this
            ->append('param.filter.message_id', 'integer')
            ->append('param.delete_time', 'integer');
    }

    // SendMessage 验证场景定义
    public function sceneSendMessage()
    {
        return $this
            ->append('data.chat_global_id', 'require')
            ->append('data.type', 'require')
            ->append('data.content', 'require')
            ->append('data.content_type', 'require');

    }

    // SendSystemNoticeMessage 验证场景定义
    public function sceneSendSystemNoticeMessage()
    {
        return $this
            ->append('data.type', 'require')
            ->append('data.receiver', 'require|integer|gt:1')
            ->append('data.content', 'require')
            ->append('data.content_type', 'require');
    }

    // SelectWithReadStatus 验证场景定义
    public function sceneSelectWithReadStatus()
    {
        return $this->append("param", "require|array")
            ->append("param.filter", "require|array");
    }

    // SelectSystemNotifyMessages 验证场景定义
    public function sceneSelectSystemNotifyMessage()
    {
        return $this->append("param", "require|array")
            ->append("param.filter", "array")
            ->append("param.page", "array")
            ->append("param.type", "require|in:unread,read");
    }

    public function sceneAddMultipleMessage()
    {
        return $this->append("data", "require|array");
    }

    public function sceneAddMultipleMessageItem()
    {
        $this->append("chat_global_id", "require")
            ->append("global_id", "require")
            ->append("type", "require")
            ->append("content", "require")
            ->append("content_type", "require|in:text,notice,file,audio,image,card_message,system_hint,link,card_message_v2")
            ->append("sent_at", "require|integer");
    }

    public function sceneRevokeMessage()
    {
        $this->append("data.id", "require")
            ->append("data.chat_global_id", "require");
    }

    // SelectReplyMessage 验证场景定义
    public function sceneSelectReplyMessage()
    {
        return $this->append("param", "require|array")
            ->append("param.filter.message_reply_id", "require");
    }

    // SelectForwardMessage 验证场景定义
    public function sceneSelectForwardMessage()
    {
        return $this->append("param", "require|array")
            ->append("param.filter.id", "require");
    }

    // SearchMessageRecord 验证场景定义
    public function sceneSearchMessageRecord()
    {
        return $this->append("param", "require|array")
            ->append("param.filter.chat_global_id", "require")
            ->append("param.filter.content", "require");
    }

    // BatchPushSystemHitMessageV2 验证场景定义
    public function sceneBatchPushSystemHitMessageV2()
    {
        return $this
            ->append("data.chat_global_id_list", "require|array")
            ->append("data.message_content", "require|array");
    }

    // BatchSendMessage 验证场景定义
    public function sceneBatchSendMessage()
    {
        return $this
            ->append("data.message", "require|array")
            ->append("data.one2one", "array");
    }

    // RemindMessageLater 验证场景定义
    public function sceneRemindMessageLater()
    {
        return $this
            ->append([
                "param.message_id" => "require|integer",
                "param.delay_time" => "require|integer",
            ]);
    }
}
